<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>${baseInfo.tableComment}基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<script type="text/html" template>
<form class="layui-form"  requrl="<#noparse>{{</#noparse> serverPath.basePath }}/${baseInfo.moduleName}/${baseInfo.classForPrefix}/get"style="padding: 0px 30px;width: 95%;margin-left: auto;margin-right: auto" lay-filter="${baseInfo.classForPrefix}DataForm">

    <div style="margin: 15px 0px;<#if baseInfo.selectOpenMode?? && baseInfo.selectOpenMode>height: 475px;<#else>height: 777px;</#if>overflow: auto;">
    <#assign colIndex=0>
    <#assign index=0>
    <#assign rowSize=codeGenConf.rowSize>
    <#assign colSize=codeGenConf.colSize>
    <#assign columnSize=codeGenConf.columnSize>

    <#list 0..rowSize-1 as i>
    <div class="layui-form-item layui-row">
        <#list 0..columnSize as col>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <label class="layui-form-label">${baseInfo.showColumns[index].columnComment!}</label>
            <div class="layui-input-block">
                <input type="text" name="${baseInfo.showColumns[index].attrNameForProperty}"  placeholder="请输入${baseInfo.showColumns[index].columnComment!}"
                       autocomplete="off" class="layui-input <#if baseInfo.showColumns[index].attrType?? && baseInfo.showColumns[index].attrType == 'Date'>dateTimeFiled time-init</#if>" maxlength="50" fieldname="${baseInfo.showColumns[index].attrNameForProperty}">
            </div>
        </div>
            <#assign lastData=index == columnSize -1>
        <#assign index=index+1>
        <#assign colIndex=colIndex+1>
        <#if colIndex % colSize == 0><#break /></#if>
            <#if lastData><#break /></#if>
        </#list>
    </div>
    </#list>

    <#if hideColumnSize>
        <#assign hideIndex=0>
        <#assign hideColIndex=0>
        <#assign hideRowSize=codeGenConf.hideRowSize>
        <#assign hideColumnSize=codeGenConf.hideColumnSize>
        <#list 0..hideRowSize-1 as i>
            <div class="layui-form-item layui-row" style="display: none;">
                <#list 0..hideColumnSize as col>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
                        <label class="layui-form-label">${baseInfo.hideColumns[hideIndex].columnComment!}</label>
                        <div class="layui-input-block">
                            <input type="text" name="${baseInfo.hideColumns[hideIndex].attrNameForProperty}"  placeholder="请输入${baseInfo.hideColumns[hideIndex].columnComment!}"
                                   autocomplete="off" class="layui-input <#if baseInfo.hideColumns[hideIndex].attrType?? && baseInfo.hideColumns[hideIndex].attrType == 'Date'>dateTimeFiled time-init</#if>" maxlength="50" fieldname="${baseInfo.hideColumns[hideIndex].attrNameForProperty}">
                        </div>
                    </div>
                    <#assign lastData=hideIndex == hideColumnSize -1>
                    <#assign hideIndex=hideIndex+1>
                    <#assign hideColIndex=hideColIndex+1>
                    <#if hideColIndex % colSize == 0><#break /></#if>
                    <#if lastData><#break /></#if>
                </#list>
            </div>
        </#list>
    </#if>
    </div>

    <div class="layui-form-item" style="position: fixed;bottom: 15px;left: 0;margin-bottom: 0;width: 100%;">
        <div style="text-align: center;">
            <#if selectFlow?? && selectFlow != "">
            <span id="hideAndShow" style="display: none;">
            <a lay-submit lay-filter="${baseInfo.classForPrefix}" class="layui-btn btn-n privateSubmit" requrl="<#noparse>{{</#noparse>serverPath.basePath}}/${baseInfo.moduleName}/${baseInfo.classForPrefix}/save">提交</a>
            <a lay-filter="${baseInfo.classForPrefix}" id="run" class="layui-btn btn-n">启动</a>
            </span>
            <#else>
                <a lay-submit lay-filter="${baseInfo.classForPrefix}" class="layui-btn btn-n privateSubmit" requrl="<#noparse>{{</#noparse>serverPath.basePath}}/${baseInfo.moduleName}/${baseInfo.classForPrefix}/save">提交</a>
            </#if>
            <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn btn-n layui-btn-danger btn-save">取消</button>
        </div>
    </div>
</form>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','common','laydate','jquery','commons'], function () {
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var commons = layui.commons;
        var dateTimeFiledLen = $(".dateTimeFiled");
        for(var i=0;i<dateTimeFiledLen.length;i++){
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                ,type: 'date'
                ,trigger: 'click'
            });
        }

        <#if baseInfo.selectOpenMode?? && baseInfo.selectOpenMode>
        //关闭当前页面
        $("#closeWindow").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
        <#else>
        //关闭当前页面
        $("#closeWindow").click(function () {
            window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.location.href = serverPath.basePath + '/${baseInfo.moduleName}/${baseInfo.classForPrefix}/view/list';
        });
        </#if>


        var runId = "<#noparse>${runId}</#noparse>";
        if(runId == null || runId == ''){
            $("#hideAndShow").show();
        }

        var common = layui.common;
        var index = parent<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.layer.getFrameIndex(window.name);
        common.updateForm({
            name:'${baseInfo.classForPrefix}DataForm',
            idValue:"<#noparse>${</#noparse>${baseInfo.primaryKey.attrNameForProperty}}",
            primary:"${baseInfo.primaryKey.attrNameForProperty}",
            updateCallback:function (data) {
                if (common.filterRecord(data)) {
                    if($(".privateSubmit")){
                        $(".privateSubmit").attr("disabled",false).css("pointer-events","auto");
                    }
                    window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.parent.layer.alert(data.msg, function (index) {
                        window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.parent.layer.close(index);
                        window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.location.href = serverPath.basePath + '/${baseInfo.moduleName}/${baseInfo.classForPrefix}/view/list';
                    });
                } else {
                    window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.parent.layer.alert(data.msg);
                }
                return false;
            }
        });
        <#if selectFlow?? && selectFlow != "">
        $("#run").click(function () {
            <#list baseInfo.columns as column>
            var ${column.attrNameForProperty} = $("input[name='${column.attrNameForProperty}']").val();
            </#list>
            var nowData = {<#list baseInfo.columns as column><#if !column_has_next>"${column.attrNameForProperty}": ${column.attrNameForProperty}<#else>"${column.attrNameForProperty}": ${column.attrNameForProperty},</#if></#list>};
            $.ajax({
                url:serverPath.workflowPath+"/${baseInfo.moduleName}/${baseInfo.classForPrefix}/run",
                type: "post",
                dataType: 'json',
                contentType : 'application/json',
                data: JSON.stringify(nowData),
                success : function (data) {
                    if (common.filterRecord(data)) {
                        window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.parent.layer.alert(data.msg, function (index) {
                            parent<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.layer.close(index);
                            window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.location.href = serverPath.basePath + '/${baseInfo.moduleName}/${baseInfo.classForPrefix}/view/list';
                        });
                    } else {
                        window<#if baseInfo.showFull?? && baseInfo.showFull>.parent</#if>.parent.layer.alert(data.msg);
                    }
                    return false;
                },
                error : function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert("启动失败！" + XMLHttpRequest.status);
                }
            })
        })
        </#if>
    });
</script>
</body>
</html>